package jp.sourceforge.akjrcp.ui.param;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.Composite;

public abstract class ParamSettingList extends AbstractGenericParamViewComposite implements ParamItem{
private String paramKey;
private String setedValue="";
private ParamItemActionListener listener;
	public ParamSettingList(Composite parent, int style, String preferenceKey,IPreferenceStore preferenceStore,String paramKey) {
		super(parent, style, preferenceKey);
		setPreferenceStore(preferenceStore);
		setParamKey(paramKey);
		
	}



	public void setParamKey(String key){
		this.paramKey=key;
	}
	
	/*
	 * this is param key,not preferenceKey
	 * (non-Javadoc)
	 * @see jp.sourceforge.akjrcp.ui.param.ParamItem#getKey()
	 */
	@Override
	public String getKey() {
		return paramKey;
	}

	@Override
	public String getValue() {
		return getSelectionItem().getName();
	}

	@Override
	public boolean isModified() {
		return !setedValue.equals(getValue());
	}

	@Override
	public void setParamItemActionListener(ParamItemActionListener listener) {
		this.listener=listener;
	}

	@Override
	public void setValue(String value) {
		setedValue=value;
		setSelectionItem(value);
		tableSelectionChanged();
	}
	
	//called when selection changed
	public void selectionChanged(){
		//log.info(setedValue+","+getValue());
		if(isModified()){
			if(listener!=null){
				//log.info("modified:");
				listener.paramItemModified(this);
			}
		}
	};

}
